package View;

import Controladores.CtrlCliente;
import Controladores.CtrlFuncionario;
import Controladores.CtrlPrincipal;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class Principal extends javax.swing.JFrame {

    private CtrlPrincipal ctrl;
    private CtrlCliente ctrl_cli;
    private CtrlFuncionario ctrl_func;

    //construtor
    public Principal(CtrlPrincipal ctrl) {
        this.ctrl = ctrl;
        initComponents();
        this.setLocationRelativeTo(null);
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);
        this.setVisible(true);
    }
    public void FecharTela(){
        int opcao = JOptionPane.showConfirmDialog(rootPane,"Deseja realmente sair?","Sair",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE);
        if(opcao==0){
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            this.dispose();
        }else{
            this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        }
           
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu5 = new javax.swing.JMenu();
        jMenu6 = new javax.swing.JMenu();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuClientes = new javax.swing.JMenu();
        menuCadastrarClientes = new javax.swing.JMenuItem();
        menuConsultarClientes = new javax.swing.JMenuItem();
        menuProdutos = new javax.swing.JMenu();
        menuCadastrarProdutos = new javax.swing.JMenuItem();
        menuConsultarProdutos = new javax.swing.JMenuItem();
        menuVendas = new javax.swing.JMenu();
        menuCadastrarVendas = new javax.swing.JMenuItem();
        menuConsultarVendas = new javax.swing.JMenuItem();
        menuFuncionarios = new javax.swing.JMenu();
        menuCadastrarFuncionarios = new javax.swing.JMenuItem();
        menuConsultarFuncionarios = new javax.swing.JMenuItem();
        menuRelatorio = new javax.swing.JMenu();
        menuGerarRelatorio = new javax.swing.JMenuItem();
        menuSair = new javax.swing.JMenu();
        menuFechar = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        menuCadastraServicos = new javax.swing.JMenuItem();
        menuCadastrarServiços = new javax.swing.JMenuItem();

        jMenu5.setText("File");
        jMenuBar2.add(jMenu5);

        jMenu6.setText("Edit");
        jMenuBar2.add(jMenu6);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        menuClientes.setForeground(new java.awt.Color(0, 51, 153));
        menuClientes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/menuCliente.png"))); // NOI18N

        menuCadastrarClientes.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        menuCadastrarClientes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Seta_verde_16x16.png"))); // NOI18N
        menuCadastrarClientes.setText("Cadastrar");
        menuCadastrarClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastrarClientesActionPerformed(evt);
            }
        });
        menuClientes.add(menuCadastrarClientes);

        menuConsultarClientes.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, 0));
        menuConsultarClientes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Seta_verde_16x16.png"))); // NOI18N
        menuConsultarClientes.setText("Consultar");
        menuConsultarClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultarClientesActionPerformed(evt);
            }
        });
        menuClientes.add(menuConsultarClientes);

        jMenuBar1.add(menuClientes);

        menuProdutos.setForeground(new java.awt.Color(0, 51, 153));
        menuProdutos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/menuProduto.png"))); // NOI18N

        menuCadastrarProdutos.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0));
        menuCadastrarProdutos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Seta_verde_16x16.png"))); // NOI18N
        menuCadastrarProdutos.setText("Cadastrar");
        menuCadastrarProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastrarProdutosActionPerformed(evt);
            }
        });
        menuProdutos.add(menuCadastrarProdutos);

        menuConsultarProdutos.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, 0));
        menuConsultarProdutos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Seta_verde_16x16.png"))); // NOI18N
        menuConsultarProdutos.setText("Consultar");
        menuConsultarProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultarProdutosActionPerformed(evt);
            }
        });
        menuProdutos.add(menuConsultarProdutos);

        jMenuBar1.add(menuProdutos);

        menuVendas.setForeground(new java.awt.Color(0, 51, 153));
        menuVendas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/menuVenda.png"))); // NOI18N

        menuCadastrarVendas.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0));
        menuCadastrarVendas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Seta_verde_16x16.png"))); // NOI18N
        menuCadastrarVendas.setText("Cadastrar");
        menuCadastrarVendas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastrarVendasActionPerformed(evt);
            }
        });
        menuVendas.add(menuCadastrarVendas);

        menuConsultarVendas.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F6, 0));
        menuConsultarVendas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Seta_verde_16x16.png"))); // NOI18N
        menuConsultarVendas.setText("Consultar");
        menuConsultarVendas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultarVendasActionPerformed(evt);
            }
        });
        menuVendas.add(menuConsultarVendas);

        jMenuBar1.add(menuVendas);

        menuFuncionarios.setForeground(new java.awt.Color(0, 51, 153));
        menuFuncionarios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/menuFuncionario.png"))); // NOI18N

        menuCadastrarFuncionarios.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F7, 0));
        menuCadastrarFuncionarios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Seta_verde_16x16.png"))); // NOI18N
        menuCadastrarFuncionarios.setText("Cadastrar");
        menuCadastrarFuncionarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastrarFuncionariosActionPerformed(evt);
            }
        });
        menuFuncionarios.add(menuCadastrarFuncionarios);

        menuConsultarFuncionarios.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F8, 0));
        menuConsultarFuncionarios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Seta_verde_16x16.png"))); // NOI18N
        menuConsultarFuncionarios.setText("Consultar");
        menuConsultarFuncionarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultarFuncionariosActionPerformed(evt);
            }
        });
        menuFuncionarios.add(menuConsultarFuncionarios);

        jMenuBar1.add(menuFuncionarios);

        menuRelatorio.setForeground(new java.awt.Color(0, 51, 153));
        menuRelatorio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/menuRelatório.png"))); // NOI18N
        menuRelatorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuRelatorioActionPerformed(evt);
            }
        });

        menuGerarRelatorio.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F9, 0));
        menuGerarRelatorio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/GerarRelatorio_16x16.png"))); // NOI18N
        menuGerarRelatorio.setText("Gerar Relatórios");
        menuGerarRelatorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuGerarRelatorioActionPerformed(evt);
            }
        });
        menuRelatorio.add(menuGerarRelatorio);

        jMenuBar1.add(menuRelatorio);

        menuSair.setForeground(new java.awt.Color(0, 51, 153));
        menuSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/menuSair.png"))); // NOI18N
        menuSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSairActionPerformed(evt);
            }
        });

        menuFechar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
        menuFechar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Excluir_16x16.png"))); // NOI18N
        menuFechar.setText("Fechar");
        menuFechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuFecharActionPerformed(evt);
            }
        });
        menuSair.add(menuFechar);

        jMenuBar1.add(menuSair);

        jMenu1.setText("Serviços");

        menuCadastraServicos.setText("Cadastrar serviços");
        menuCadastraServicos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastraServicosActionPerformed(evt);
            }
        });
        jMenu1.add(menuCadastraServicos);

        menuCadastrarServiços.setText("Consultar serviços");
        menuCadastrarServiços.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuCadastrarServiçosActionPerformed(evt);
            }
        });
        jMenu1.add(menuCadastrarServiços);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 654, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(109, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuCadastrarClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastrarClientesActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaCadastroCliente();
}//GEN-LAST:event_menuCadastrarClientesActionPerformed

    private void menuConsultarClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConsultarClientesActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaConsultaClientes();
}//GEN-LAST:event_menuConsultarClientesActionPerformed

    private void menuSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSairActionPerformed
        // TODO add your handling code here:
        this.FecharTela();
}//GEN-LAST:event_menuSairActionPerformed

    private void menuCadastrarProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastrarProdutosActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaCadastroProduto();
}//GEN-LAST:event_menuCadastrarProdutosActionPerformed

    private void menuConsultarProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConsultarProdutosActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaConsultaProdutos();
}//GEN-LAST:event_menuConsultarProdutosActionPerformed

    private void menuCadastrarVendasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastrarVendasActionPerformed
        // TODO add your handling code here:
        //
}//GEN-LAST:event_menuCadastrarVendasActionPerformed

    private void menuConsultarVendasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConsultarVendasActionPerformed
        // TODO add your handling code here:
        //
}//GEN-LAST:event_menuConsultarVendasActionPerformed

    private void menuCadastrarFuncionariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastrarFuncionariosActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaCadastroFuncionario();
}//GEN-LAST:event_menuCadastrarFuncionariosActionPerformed

    private void menuConsultarFuncionariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConsultarFuncionariosActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaConsultaFuncionario();
        //
}//GEN-LAST:event_menuConsultarFuncionariosActionPerformed

    private void menuFecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFecharActionPerformed
        // TODO add your handling code here:
        this.FecharTela();
}//GEN-LAST:event_menuFecharActionPerformed

    private void menuRelatorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuRelatorioActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaGerarRelatorio();
    }//GEN-LAST:event_menuRelatorioActionPerformed

    private void menuGerarRelatorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuGerarRelatorioActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaGerarRelatorio();
}//GEN-LAST:event_menuGerarRelatorioActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        this.FecharTela();
    }//GEN-LAST:event_formWindowClosing

    private void menuCadastraServicosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastraServicosActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaCadastroServico();
    }//GEN-LAST:event_menuCadastraServicosActionPerformed

    private void menuCadastrarServiçosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuCadastrarServiçosActionPerformed
        // TODO add your handling code here:
        ctrl.IniciaConsultaServicos();
    }//GEN-LAST:event_menuCadastrarServiçosActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuItem menuCadastraServicos;
    private javax.swing.JMenuItem menuCadastrarClientes;
    private javax.swing.JMenuItem menuCadastrarFuncionarios;
    private javax.swing.JMenuItem menuCadastrarProdutos;
    private javax.swing.JMenuItem menuCadastrarServiços;
    private javax.swing.JMenuItem menuCadastrarVendas;
    private javax.swing.JMenu menuClientes;
    private javax.swing.JMenuItem menuConsultarClientes;
    private javax.swing.JMenuItem menuConsultarFuncionarios;
    private javax.swing.JMenuItem menuConsultarProdutos;
    private javax.swing.JMenuItem menuConsultarVendas;
    private javax.swing.JMenuItem menuFechar;
    private javax.swing.JMenu menuFuncionarios;
    private javax.swing.JMenuItem menuGerarRelatorio;
    private javax.swing.JMenu menuProdutos;
    private javax.swing.JMenu menuRelatorio;
    private javax.swing.JMenu menuSair;
    private javax.swing.JMenu menuVendas;
    // End of variables declaration//GEN-END:variables
}
